n=5
target=6
nums=[1,2,3,4,5]

def doubleB(n,target,nums):
    bucket=[0 for _ in range(6)]

    for i in range(n):
        bucket[nums[i]%target]+=1

    count=0
    for i in range(target):
        j=(target-i-1)%target

        if j<i:
            break
        if j==i:
            count+=(bucket[i]-1)*bucket[i]/2
        if j>i:
            count+=bucket[i]*bucket[j]
    print(count)

doubleB(n,target,nums)